import { createRouter, createWebHistory } from 'vue-router'

const router = createRouter({
  history: createWebHistory(import.meta.env.BASE_URL),
  routes: [
    {
      path: '/',
      name: 'Login',
      component: () => import('../views/login.vue')
    },
    {
      path: '/home',
      name: 'Home',
      component: () => import('../views/home.vue'),
      children:[
        {
          path:'/shouye',
          name: 'Shouye',
          component: () => import('../views/shouye.vue')
        },
        {
          path: '/people',
          name: 'People',
          component: () => import('../views/people.vue')
        },
        {
          path: '/service',
          name: 'Service',
          component: () => import('../views/service.vue')
        },
        {
          path: '/order',
          name: 'Order',
          component: () => import('../views/order.vue')
        },
        {
          path: '/fankui',
          name: 'Fankui',
          component: () => import('../views/fankui.vue')
        },
        {
          path: '/notice',
          name: 'Notice',
          component: () => import('../views/notice.vue')
        },
        {
          path:'/sushe',
          name:'Sushe',
          component:()=>import('../views/sushe.vue')
        }
      ]
    }
  ],
})

router.beforeEach((to, from, next) => {
  if (!localStorage.getItem('denglu')) {
        router.replace({name:'Login'})
} else {
    next()
}

})

export default router
